package cn.jbolt.ai.resource.llm.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jboltai.resource.ai.AIModel;
import io.swagger.v3.oas.annotations.media.Schema;

import java.io.Serializable;
import java.util.Date;

/**
 * AI资源表
 */
@TableName("ja_ai_resource") // 指定数据库表名
public class AiResource implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.ASSIGN_ID)
    private Long id;

    @Schema(name = "type", description = "类型")
    @TableField("type")
    private String type;

    @Schema(name = "name", description = "资源名称")
    @TableField("name")
    private String name;


    @Schema(name = "defaultModel", description = "默认模型型号")
    @TableField("default_model")
    private String defaultModel;

    @Schema(name = "apiKey", description = "大模型需要的APIKEY")
    @TableField("api_key")
    private String apiKey;

    @Schema(name = "apiSecret", description = "大模型需要的SECRET KEY")
    @TableField("api_secret")
    private String apiSecret;

    @Schema(name = "apiUrl", description = "接口地址")
    @TableField("api_url")
    private String apiUrl;


    @Schema(name = "limits", description = "频率限制，格式[{unit:''day'', times: 10}],就是一个json串")
    @TableField("limits")
    private String limits;


    @TableField("enable")
    @Schema(name = "enable", description = "是否开启")
    private Boolean enable;


    @Schema(name = "createTime", description = "创建时间")
    @JsonFormat(locale = "zh", pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;

    //以下是非数据库字段
    @TableField(exist = false)
    private String modelName;

    public String getDefaultModel() {
        return defaultModel;
    }

    public void setDefaultModel(String defaultModel) {
        this.defaultModel = defaultModel;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getApiKey() {
        return apiKey;
    }

    public void setApiKey(String apiKey) {
        this.apiKey = apiKey;
    }

    public String getApiSecret() {
        return apiSecret;
    }

    public void setApiSecret(String apiSecret) {
        this.apiSecret = apiSecret;
    }

    public String getApiUrl() {
        return apiUrl;
    }

    public void setApiUrl(String apiUrl) {
        this.apiUrl = apiUrl;
    }

    public String getLimits() {
        return limits;
    }

    public void setLimits(String limits) {
        this.limits = limits;
    }

    public Boolean getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getModelName() {
        return  AIModel.get(type).getName();
//        return modelName;
    }

    public void setModelName(String modelName) {
        this.modelName = modelName;
    }
}